package com.example.vpdemo;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ProgressBar;

import java.util.ArrayList;

import androidx.core.widget.ContentLoadingProgressBar;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


public class FragmentC1 extends Fragment {

    View view;
    private RecyclerView rl;
    private Button btn;
    private ContentLoadingProgressBar progressBar;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        if (view == null) {
            view = inflater.inflate(R.layout.fragment_a, container, false);
        }



        initView(view);
        return view;
    }

    private void initView(View view) {


        rl = (RecyclerView) view.findViewById(R.id.rl);

        final ArrayList<String> strings = new ArrayList<>();
        for (int i = 0; i < 50; i++) {
            strings.add("the " + i + "ge ");
        }

        MyAdapter adapter = new MyAdapter(getContext(), strings);

        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()) ;

        rl.setLayoutManager(layoutManager);

        rl.setAdapter(adapter);

        adapter.setOnClick(new MyAdapter.PassPosition() {
            @Override
            public void pass(int position) {
                startActivity(new Intent(getActivity(), Main2Activity.class));
//                Toast.makeText(getActivity(), ""+strings.get(position), Toast.LENGTH_SHORT).show();
            }
        });

    }
}
